package com.showwindow.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.market.options.dao.OptionsDao;
import com.market.options.domain.OptionsCommand;
import com.market.product.dao.ProductDao;
import com.market.product.domain.ProductCommand;

@Controller
public class ShowwindowDetailController {
	@Autowired
	ProductDao productDao;	
	@Autowired
	OptionsDao optionsDao;
	
	@RequestMapping("/showwindowDetail.do")
	public ModelAndView processDetail(@RequestParam("product")int p_code){
		ProductCommand command = productDao.select(p_code);
		String images[] = command.getImage().split("&");	
		
		List<OptionsCommand> options = optionsDao.list(p_code);
		
		ModelAndView mav = new ModelAndView();
		mav.setViewName("showwindowDetail");
		mav.addObject("command", command);
		mav.addObject("options", options);		
		mav.addObject("images", images);		
		return mav;
	}
}
